#!ipxe

goto ${menu} ||

:live_menu
set os Q4OS Live
menu ${os}
item --gap ${os} Versions
item 4.6 ${space} ${os} 4.6
choose live_version || goto live_exit
menu ${os} ${live_version}
item --gap ${os} Flavors
goto ${live_version}

:4.6
{% for key, value in endpoints.items() | sort %}
{% if value.os == "Q4OS" and 'squash' in key and value.version == "4.6" %}
item {{ key }} ${space} {{ value.os | title }} {{ value.version }} {{ value.flavor | title}}
{% endif %}
{% endfor %}
goto flavor_select

:flavor_select
choose flavor || goto live_menu
echo ${cls}
goto ${flavor} ||

{% for key, value in endpoints.items() | sort %}
{% if value.os == "Q4OS" and 'squash' in key %}
{% set kernel_name = value.kernel %}
:{{ key }}
set squash_url ${live_endpoint}{{ value.path }}filesystem.squashfs
{% for key, value in endpoints.items() | sort %}
{% if key == kernel_name %}
set kernel_url ${live_endpoint}{{ value.path }}
{% endif %}
{% endfor %}
goto q4os-boot
{% endif %}
{% endfor %}

:q4os-boot
imgfree
kernel ${kernel_url}vmlinuz boot=live fetch=${squash_url} {{ kernel_params }}
initrd ${kernel_url}initrd
boot

:live_exit
clear menu
exit 0

